<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
</body>
</html>

<script>
  function fn() {
    // 每一个函数都会有一个arguments的对象
    // 这个包含了所有接受到的参数，组成了一个类数组
    // console.log(arguments.length);
    // console.log(arguments[2]);

    for(var i = 0, sum = 0; i < arguments.length; i++) {
      // console.log(arguments[i]);
      sum += arguments[i];
    }
    return sum;
  }

  console.log(fn(1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,45,123,4365,23,1,645,8567,234,345));
  console.log(fn(1,2,3,4,5,6,7,8,9,10,11,12,1,2,3,45));
</script>